/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package dao;

import java.util.ArrayList;
import model.dao.ulti.HibernateUtil;
import org.hibernate.Query;
import org.hibernate.Session;
import pojo.SinhVien;

/**
 *
 * @author Suma
 */
public class SinhVienDAO {
    public SinhVienDAO(){
        
    }
    /*
    public static String getAllJSON() {
        Session session = HibernateUtil.getSessionFactory().openSession();
        String hql = "from SinhVien s ";
        Query query = session.createQuery(hql);
        ArrayList<SinhVien> dssv = (ArrayList<SinhVien>) query.list();
        StringBuilder cb = new StringBuilder();
        cb.append("{\"count\":\"").append(dssv.size()).append("\", \"SinhVienList\":[");
        for (int i = 0; i < dssv.size(); i++) {
            SinhVien sv = dssv.get(i);
            cb.append(sv.toJSON());
            if (i + 1 < dssv.size()) {
                cb.append(",");
            }
        }
        cb.append("]}");

        return cb.toString();
    }
    */

    public ArrayList<SinhVien> getList() {
        ArrayList<SinhVien> ds = null;
        Session session = HibernateUtil.getSessionFactory().openSession();
        String hql = "from SinhVien s ";
        Query query = session.createQuery(hql);
        ds = (ArrayList<SinhVien>) query.list();
        session.close();
        return ds;

    }
}
